home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 235_01 / ov.c < prev    next >
Text File  |  1987-06-16  |  15KB  |  398 lines

  1. /*  093  27-Feb-87  ov.c
  2.  
  3.                             O V E R V I E W
  4.  
  5.         This program allows the user to perform common operations on
  6.         disk files in a visual, tabular manner.
  7.  
  8.         Copyright (c) 1987 by Blue Sky Software.  All rights reserved.
  9. */
  10.  
  11. #define VERSION "OverView 1.02, 1-Mar-87"
  12.  
  13. #include <stdio.h>
  14. #include <setjmp.h>
  15. #include <dos.h>
  16. #include "ov.h"
  17.  
  18.  
  19. int brkhit;                            /* NZ when ^Break/^C hit */
  20. int winupdate;                         /* NZ when windows need updating */
  21. unsigned char anyshowall;              /* NZ when show all is active */
  22. unsigned char dir_display;             /* NZ when dir tree displayed */
  23. unsigned char def_display;             /* NZ when define screen displayed */
  24. unsigned char help_display;            /* NZ when help is active */
  25. unsigned char view_display;            /* NZ when viewing a file */
  26. unsigned char restricted;              /* NZ when some functions disabled */
  27.  
  28. char *ovname = NULL;                   /* name used to invoke (if >= DOS 3) */
  29.  
  30. char *initialdir;                      /* name of initial dir */
  31.  
  32. unsigned int dataseg;                  /* ov's data segment reg value */
  33.  
  34. FILE_ENT files[MAX_FILES];             /* array of file entries */
  35.  
  36. char *cantopen = "Can't open ";        /* common message */
  37.  
  38. jmp_buf back_to_main;                  /* error handling jmp_buf block */
  39.  
  40. extern unsigned char _osmajor;         /* DOS major version # */
  41.  
  42. /* function declarations */
  43.  
  44. char *getcwd();
  45. FILE_ENT *nxtfile();
  46. int sel_all(), define(), help(), show_all();
  47. int quit(), login(), erase_current(), erase_tagged(), view(), sortname();
  48. int copy_current(), copy_tagged(), info(), renew(), do_cmd(), spawn_cli();
  49. int dtree(), dir_login(), dir_mkdir(), dir_rmdir(), dir_exit(), sel_attrib();
  50. int ren_cur(), ren_tag(), set_mask(), clr_mask(), invert_mask(), sel_tagged();
  51. int sort_asc(), sort_desc(), sort_name(), sort_ext(), sort_date(), sort_size();
  52. int set_vol(), tag_current(), tag_name(), tag_date(), tag_reset(), tag_today();
  53. int tag_modified(), tag_invert(), attrib_current(), attrib_tagged(), execute();
  54. int win_open(), win_close(), win_expand(), win_next(), win_prev(), sort_none();
  55.  
  56. /* define the current window structure */
  57.  
  58. struct window cw = { NULL, NULL, 0, FIRST_NROW, NAME_ROWS, FIRST_NROW,
  59.    NAME_ROWS, 0, 0, 0, 0, 0, 0, 0, NULL, 0, 0, 0, 0, NULL, 'A', sortname, 0, 0,
  60.    RDONLY | HIDDEN | SYSTEM | DIR | ARCHIVE, 1 };
  61.  
  62. /* define some of the menus */
  63.  
  64. char current[] = "Current";
  65. char tagged[] = "Tagged";
  66.  
  67. extern MENU top_file_menu[], top_dir_menu[];
  68.  
  69. MENU *top_menu = top_file_menu;
  70.  
  71. MENU attrib_menu[] = {
  72.    { current,"Change the current file's attributes", attrib_current, NULL },
  73.    { tagged, "Change the attributes of all tagged files", attrib_tagged, NULL },
  74.    { NULL, NULL, NULL, NULL }
  75. };
  76.  
  77. MENU copy_menu[] = {
  78.    { current, "Copy the current file", copy_current, NULL },
  79.    { tagged, "Copy the tagged files", copy_tagged, NULL },
  80.    { NULL, NULL, NULL, NULL }
  81. };
  82.  
  83. MENU erase_menu[] = {
  84.    { current, "Erase the current file", erase_current, NULL },
  85.    { tagged, "Erase all tagged files", erase_tagged, NULL },
  86.    { NULL, NULL, NULL, NULL }
  87. };
  88.  
  89. MENU mask_menu[] = {
  90.    { "Set", "Set the file mask", set_mask, NULL },
  91.    { "Clear", "Clear the file mask", clr_mask, NULL },
  92.    { "Invert", "Invert the meaning of the mask", invert_mask, NULL },
  93.    { NULL, NULL, NULL, NULL }
  94. };
  95.  
  96. MENU ren_menu[] = {
  97.    { current, "Rename or move the current file", ren_cur, NULL },
  98.    { tagged, "Move all tagged files", ren_tag, NULL },
  99.    { NULL, NULL, NULL, NULL }
  100. };
  101.  
  102. MENU select_menu[] = {
  103.    { "Attrib", "Set selection attributes", sel_attrib, NULL },
  104.    { "Mask", "Set, Clear, or Invert file name selection mask", NULL, mask_menu },
  105.    { "Reset", "Reset selection criteria to defaults", sel_all, NULL },
  106.    { "Showall", "Toggle selection of all files on current drive", show_all, NULL },
  107.    { "Tagged", "Select all tagged files", sel_tagged, NULL },
  108.    { NULL, NULL, NULL, NULL }
  109. };
  110.  
  111. MENU sort_submenu[] = {
  112.    { "Ascending", "Sort files in ascending order", sort_asc, NULL },
  113.    { "Descending", "Sort files in descending order", sort_desc, NULL },
  114.    { NULL, NULL, NULL, NULL }
  115. };
  116.  
  117. MENU sort_menu[] = {
  118.    { "Name", "Sort by primary name", sort_name, NULL },
  119.    { "Ext", "Sort by extension", sort_ext, NULL },
  120.    { "Date", "Sort by date", sort_date, NULL },
  121.    { "Size", "Sort by size", sort_size, NULL },
  122.    { "Options", "Set sort options", NULL, sort_submenu },
  123.    { "Unsorted", "Do not sort entries", sort_none, NULL },
  124.    { NULL, NULL, NULL, NULL }
  125. };
  126.  
  127. MENU tag_menu[] = {
  128.    { current, "Tag/Untag the current file", tag_current, NULL },
  129.    { "Date", "Tag files by date and time", tag_date, NULL },
  130.    { "Invert", "Invert the tag state of all files", tag_invert, NULL },
  131.    { "Modified", "Tag files with Archive attribute", tag_modified, NULL },
  132.    { "Name", "Tag files by name", tag_name, NULL },
  133.    { "Reset", "Untag all files", tag_reset, NULL },
  134.    { "Today", "Tag all files created/modified today", tag_today, NULL },
  135.    { NULL, NULL, NULL, NULL }
  136. };
  137.  
  138. MENU win_menu[] = {
  139.    { "Open", "Open an additional window", win_open, NULL },
  140.    { "Close", "Close the current window", win_close, NULL },
  141.    { "Expand", "Expand the current window to full screen (closes others)",
  142.                                                          win_expand, NULL },
  143.    { "Next", "Switch to the next window", win_next, NULL },
  144.    { "Prev", "Switch to the previous window", win_prev, NULL },
  145.    { NULL, NULL, NULL, NULL }
  146. };
  147.  
  148. MENU other_menu[] = {
  149.    { "Attrib", "Change the attributes of one or more files", NULL, attrib_menu },
  150.    { "Command", "Execute a single DOS command", do_cmd, NULL },
  151.    { "Define", "Define screen parameters", define, NULL },
  152.    { "Interperter", "Spawn a DOS command interpreter", spawn_cli, NULL },
  153.    { "Select", "Set file selection criteria", NULL, select_menu },
  154.    { "Volume", "Create or change the volume label", set_vol, NULL },
  155.    { "Window", "Open, close, switch file display windows", NULL, win_menu },
  156.    { "Xecute", "Execute a program, command, or batch file", execute, NULL },
  157.    { "Other", "Help, Copy, Dir, Erase, Info, Login, New, Rename, Sort, Tag, View, Quit", NULL, top_file_menu },
  158.    { NULL, NULL, NULL, NULL }
  159. };
  160.  
  161. MENU top_file_menu[] = {
  162.    { "Help", "Get help on using OVERVIEW", help, NULL },
  163.    { "Copy", "Copy one or more files", NULL, copy_menu },
  164.    { "Dir", "Display the disk's directory tree", dtree, top_dir_menu },
  165.    { "Erase", "Erase (delete) one or more files", NULL, erase_menu },
  166.    { "Info", "Toggle display of extra file information", info, NULL },
  167.    { "Login", "Login (switch) to another disk/directory", login, NULL },
  168.    { "New", "Reread and redisplay the directory", renew, NULL },
  169.    { "Rename", "Rename or move one or more files", NULL, ren_menu },
  170.    { "Sort", "Sort the file entries by Name, Extension, Date, or Size", NULL, sort_menu },
  171.    { "Tag", "Tag one or more files", NULL, tag_menu },
  172.    { "View", "View the current file", view, NULL },
  173.    { "Other", "Attrib, Command, Define, Interperter, Select, Volume, Window, Xecute", NULL, other_menu },
  174.    { "Quit", "Exit OVERVIEW and return to DOS", quit, NULL },
  175.    { NULL, NULL, NULL, NULL }
  176. };
  177.  
  178.  
  179.  
  180. /******************************************************************************
  181.  **                           M A I N                                        **
  182.  *****************************************************************************/
  183.  
  184. main(argc,argv)
  185. int argc;
  186. char *argv[];
  187. {
  188.    setvattrib(DIS_NORM);       /* select initial video attribute */
  189.  
  190.    /* display the signon while initializing */
  191.  
  192.    init_tty();                         /* init the terminal settings */
  193.    ovlogo(VERSION);                    /* display the logo screen */
  194.  
  195.    /* init internal data structures and display a screen of files */
  196.  
  197.    {  struct SREGS sr;                 /* get OverView's data seg reg value */
  198.       segread(&sr);                    /*   for a couple of other routines  */
  199.